package io.renren.modules.lanling.service.impl;

import cn.hutool.core.lang.Validator;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.lanling.dao.NoticeDao;
import io.renren.modules.lanling.entity.NoticeEntity;
import io.renren.modules.lanling.service.NoticeService;


@Service("noticeService")
public class NoticeServiceImpl extends ServiceImpl<NoticeDao, NoticeEntity> implements NoticeService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        EntityWrapper<NoticeEntity> entityWrapper = new EntityWrapper<>();

        Object name = params.get("name");
        if (Validator.isNotEmpty(name)) {
            entityWrapper.like("title", name.toString());
        }

        Page<NoticeEntity> page = this.selectPage(
                new Query<NoticeEntity>(params).getPage(),entityWrapper);

        return new PageUtils(page);
    }

}
